package io.gitee.xyuesheng.day04;

import java.util.Timer;
import java.util.TimerTask;

public class DemoTimer3 {
    TimerTask task1 = new TimerTask() {
        @Override
        public void run() {
            System.out.println("xxx...");
        }
    };//不要忘记结束的分号“;”

    public static void main(String[] args) {
        Timer timer = new Timer();

//        timer.schedule(new TimerTask() {
//            @Override
//            public void run() {
//                System.out.println("异步任务。。。");
//            }
//        },1000);

        //匿名内部类
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                System.out.println("异步任务。。。");
            }
        };//不要忘记结束的“;”

        timer.schedule(task, 1000);


    }
}
